package com.ruoyi.common.core.domain.entity;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.utils.DateUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;

import java.time.LocalDate;
import java.util.Calendar;
import java.util.Date;

/**
 * 测试对象 sys_lu
 *
 * @author ruoyi
 * @date 2024-01-20
 */
public class SysLu extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 用户ID */
    private Long userId;

    /** 用户账号 */
    @Excel(name = "用户账号")
    private String userName;

    /** 用户邮箱 */
    @Excel(name = "用户邮箱")
    private String email;

    /** 手机号码 */
    @Excel(name = "手机号码")
    private String phonenumber;

    /** 用户性别（0男 1女 2未知） */
    @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
    private String sex;

    /** 密码 */
    @Excel(name = "密码")
    private String password;

    /** 删除标志（0代表存在 2代表删除） */
    private String delFlag;

    /** 密码最短长度 */
    @Excel(name = "密码最短长度")
    private Long passwordMinLength;

    /** 用户名最短长度 */
    @Excel(name = "用户名最短长度")
    private Long nameMinLength;

    /** 密码剩余次数 */
    @Excel(name = "密码剩余次数")
    private Long passOp;


    /** 密码到期时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "密码到期时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date passwordExpireTime;

    public Date getPwdTime() {
        return pwdTime;
    }

    public void setPwdTime(Date pwdTime) {
        this.pwdTime = pwdTime;
    }

    /**密码更新时间*/
    private Date pwdTime;

    public void setUserId(Long userId)
    {
        this.userId = userId;
    }

    public Long getUserId()
    {
        return userId;
    }
    public void setUserName(String userName)
    {
        this.userName = userName;
    }

    public String getUserName()
    {
        return userName;
    }
    public void setEmail(String email)
    {
        this.email = email;
    }

    public String getEmail()
    {
        return email;
    }
    public void setPhonenumber(String phonenumber)
    {
        this.phonenumber = phonenumber;
    }

    public String getPhonenumber()
    {
        return phonenumber;
    }
    public void setSex(String sex)
    {
        this.sex = sex;
    }

    public String getSex()
    {
        return sex;
    }
    public void setPassword(String password)
    {
        this.password = password;
    }

    public String getPassword()
    {
        return password;
    }
    public void setDelFlag(String delFlag)
    {
        this.delFlag = delFlag;
    }

    public String getDelFlag()
    {
        return delFlag;
    }
    public void setPasswordMinLength(Long passwordMinLength)
    {
        this.passwordMinLength = passwordMinLength;
    }

    public Long getPasswordMinLength()
    {
        return passwordMinLength;
    }
    public void setNameMinLength(Long nameMinLength)
    {
        this.nameMinLength = nameMinLength;
    }

    public Long getNameMinLength()
    {
        return nameMinLength;
    }
    public void setPassOp(Long passOp)
    {
        this.passOp = passOp;
    }

    public Long getPassOp()
    {
        return passOp;
    }

    public Date getPasswordExpireTime() {
        return passwordExpireTime;
    }

    public void setPasswordExpireTime(Date pwdTime, int daysToSubtract) {
        this.passwordExpireTime = subtractDaysFromDate(pwdTime, daysToSubtract);
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
                .append("userId", getUserId())
                .append("userName", getUserName())
                .append("email", getEmail())
                .append("phonenumber", getPhonenumber())
                .append("sex", getSex())
                .append("password", getPassword())
                .append("delFlag", getDelFlag())
                .append("createTime", getCreateTime())
                .append("updateBy", getUpdateBy())
                .append("updateTime", getUpdateTime())
                .append("passwordMinLength", getPasswordMinLength())
                .append("passwordExpireTime", getPasswordExpireTime())
                .append("nameMinLength", getNameMinLength())
                .append("passOp", getPassOp())
                .toString();
    }

    // 这个方法减去指定的天数，并返回一个新的Date对象
    public Date subtractDaysFromDate(Date date, int daysToSubtract) {
        // 创建一个Calendar实例并设定为提供的日期
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);

        // 从日期中减去天数
        calendar.add(Calendar.DAY_OF_MONTH, -daysToSubtract);

        // 获取新的日期并返回
        return calendar.getTime();
    }

}
